//index.js
//获取应用实例
const app = getApp()
const Pager = require('components/aotoo/core')


let mkModal = require('components/modules/modal')

Pager({
  data: {
    pages: Pager.list({
      type :{
        is: 'scroll', 
        'scroll-y': true
      },
      data: [
        {
          title: '中间弹出层',
          body: [
            {title: '带动画', itemClass: 'item', aim: 'onModal?type=middle&animate=true'},
            {title: '无动画', itemClass: 'item', aim: 'onModal?type=middle&animate=false'}
          ],
          bodyClass: 'btn-footer mt-primary'
        },
        {
          title: '底部弹出层',
          body: [
            {title: '带动画', itemClass: 'item', aim: 'onModal?type=bottom&animate=true'},
            {title: '无动画', itemClass: 'item', aim: 'onModal?type=bottom&animate=false'}
          ],
          bodyClass: 'btn-footer mt-primary'
        },
        {
          title: '顶部弹出层',
          body: [
            {title: '带动画', itemClass: 'item', aim: 'onModal?type=top&animate=true'},
            {title: '无动画', itemClass: 'item', aim: 'onModal?type=top&animate=false'}
          ],
          bodyClass: 'btn-footer mt-primary'
        },
      ],
      header: {
        '@item': {
          id: 'toast1'
        }
      },
      listClass: 'hei-p100',
      itemClass: 'm-default'
    }),
    modal: { $$id: 'actionSide1' }
  },
  modal: null,
  toast: null,
  onModal(e, parmas, inst) {
    const { type, animate } = parmas
    this.modal.update(mkModal({
      data: type === 'bottom' && animate ? {
        title: [
          {title:'弹窗标题', itemClass: 'title-primary ml-default'},
          {title: ' ', itemClass: 'icon-close click-icon-width', aim: 'onClose'}
        ],
        body: [
          {title: '大标题', itemClass: 'title-default no-lh mb-default'},
          {title: '中标题', itemClass: 'title-primary no-lh mb-default'},
          {title: '小标题', itemClass: 'size no-lh mb-default fw-bold'},
          {title: '文章正文字体字号文章正文字体字号文章正文字体字 文章正文字体字号文章正文字体字号文章正文字体字 文章正文字体字号文章正文字体字号文文章正文字体字号文章正文字体字号文章正文字体字 文章正文字体字号文章正文字体字号文章正文字体字 文章正文字体字号文章正文字体字号文文章正文字体字号文章正文字体字号文', itemClass: 'size no-lh-x'},
        ],
        titleClass: 'title-height flex-row-between',
        bodyClass: 'item-body scroll'
      } : {
        title: {
          title: '需要您的授权',
          itemClass: 'title-primary no-lh ss-center mb-default'
        } ,
        body: [{title: '开启微信用户信息授权，即可享受更多服务哦~', itemClass: 'size no-lh-x'}],
        footer: [{title: '取消', itemClass: 'ss-button btn-grey plain', aim: 'onClose'}, {title: '确定', itemClass: 'ss-button btn-default'}],
        footerClass: 'btn-footer mt50',
      },
      actionSideClass: type === 'middle' ? 'modal-normal' : type === 'bottom' && animate  ? 'radius' : '',
      direction: type,
      animate: animate
    }))
  },
  onClose(e, params, inst){
    this.modal.onHide()
  },
  onShow: function () {},
  onReady: function () {
    this.modal = this.getElementsById('actionSide1')
    this.toast = this.getElementsById('toast1')
    const that = this
    setTimeout(() => {
      that.toast.update(mkModal({
        data: {
          title: '注意！注意！注意！！！我本是一个toast'
        },
        close: true,
        type: 'toast',
        actionSideWrapClass: 'ss-tag tag-fail larger '
      }))
    }, 100);
  },
  onLoad: function () {
    
  }
})
